package cn.kgc.springboot.config;

import cn.kgc.springboot.common.JWTHandlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: mosin
 * @version: v1.0  2022/8/5
 */
@Configuration
public class JWTConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        JWTHandlerInterceptor jwtHandlerInterceptor = new JWTHandlerInterceptor();
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(jwtHandlerInterceptor);
        interceptorRegistration.addPathPatterns("/**")
                .excludePathPatterns("/user/login", "/login.html", "/assets/**");
    }
}
